import request from './network.js';
import { https } from '../utils/http.js';


export function getProductList() {
  return request({
    url: https.getProductList
  })
}

export function getProductPrice(id, data) {
  return request({
    url: `${https.getProductPrice}/${id}/prices`,
    data,
    method: 'POST',
    showOnload:true
  })
}
export function payment(data) {
  return request({
    url: https.payment,
    data,
    method: 'POST',
    header: {
      'token': wx.getStorageSync('token'),
      'content-type': 'application/json'
    },
    type: 1 // 1 后续成立--> 'content-type': 'application/json'
  })
}
export function requestPayment(data, success, fail) { // 调用支付接口
  wx.requestPayment({
    'timeStamp': data.timeStamp,
    'nonceStr': data.nonceStr,
    'package': data.package,
    'signType': data.signType,
    'paySign': data.paySign,
    'success'(res) {
      success(res)
    },
    'fail'(err) {
      fail(err)
      return;
    }
  });
}
export function notifying(orderNum) { // 支付回调（生成订单）
  return request({
    url: https.notifying,
    data: {out_trade_no:orderNum},
    method: 'POST',
    header: {
      'token': wx.getStorageSync('token'),
      'content-type': 'application/json'
    },
    type: 1 // 1 后续成立--> 'content-type': 'application/json'
  })
}
